const state = {
    isMyToDoList: 0, //流程值判断
    role: {}, //获取流程表格中每一列表中的数据
    userId: '',
    custInf: {
        custName: '',
        custId: '',
        eSignAccount: ''
    },
    custInf2: {},
    sourcePageCode: '', //从哪个页面进入
    myProcessedCTCode: '', //我的待办 存放组件code
    ApplyReportInfoCode:0  //融资申请列表
}
const getters = {
    MyToDoListStatus: state => {
        return state.isMyToDoList;
    },
    ApplyReportInfoCodeStatus: state => {
        return state.ApplyReportInfoCode;
    },
}
const mutations = {
    myToDoList(state, payload) {
        state.isMyToDoList = payload.isMyToDoList
    },
    geRole(state, payload) {
        state.role = payload.role
    },
    updateUser(state, payload) {
        state.userId = payload.userId
    },
    updateMyProcessedCTCode(state, { payload }) {
        state.myProcessedCTCode = payload
    },
    ApplyReportInfo(state, payload) {
        state.ApplyReportInfoCode = payload.ApplyReportInfoCode
    },
}

const actions = {
    changeMyProcessedCTCode({ commit }, payload) {
        commit({
            type: 'updateMyProcessedCTCode',
            payload
        })
    },
    changeTOdo({ commit }, payload) {
        commit({
            type: 'myToDoList',
            isMyToDoList: payload.isMyToDoList,
        })
    },
    changeRole({ commit }, payload) {
        commit({
            type: 'geRole',
            role: payload.role,
        })
    },
    changeApplyReportInfo({ commit }, payload) {
        commit({
            type: 'ApplyReportInfo',
            ApplyReportInfoCode: payload.ApplyReportInfoCode,
        })
    },
    queryMstSupplierInfo({ commit }, payload) {
        let _this = this
        _this._vm.$http.queryMstSupplierInfo({ mainAccount: payload.mainAccount }).then(res => {
            if (res.data.code == '200') {
                let data = res.data.rows;
                state.custInf.custName = data[0].supplierName
                state.custInf.custId = data[0].id
                state.custInf.eSignAccount = data[0].eSignAccount
                state.custInf.mail = data[0].mail
                state.custInf.weChatNo = data[0].weChatNo
                state.custInf2 = data[0]
                state.custInf2.customerId = data[0].id
                state.custInf2.customerCode = data[0].supplierCode
                state.custInf2.customerName = data[0].supplierName
                state.custInf2.customerType = data[0].categoryCode
            } else {

            }
        }).catch(err => {})
    },

    // getSDetailByAct({commit},payload) {
    //   let _this=this
    //   var params={"mainAccount":"G100346"}
    //   _this._vm.$http.getSDetailByAct(params).then(res=>{
    //     console.log(res)
    //   }).catch(err => {
    //     // _this.$alert("查询失败，请检查网络！", {
    //     //   confirmButtonText: "确定",
    //     //   customClass: "alertFailure"
    //     // });
    //   })
    // },

}

export default {
    state,
    mutations,
    actions,
    getters
}